<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserInfoAccessTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //用户和个人信息关联表
        Schema::create ('user_info_access', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('user_id');//uuid主键
            $table->uuid ('info_id');//uuid主键
            $table->primary (['user_id', 'info_id']);//
            $table->foreign ('user_id')->references ('id')->on ('users')->onDelete ('cascade');//用户外键
            $table->foreign ('info_id')->references ('id')->on ('user_info')->onDelete ('cascade');//个人信息外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('user_info_access');
    }
}
